<template>
  <div class="role">
    <div class="resultRoleBox">
      <div
        class="roleBox"
        v-for="(value, key) in roleList"
        :key="key"
      >
        <img :src="baseUrl+'/'+value" class="imgUrl" />
        <div class="countBox" v-if="!isNaN(Number(key.charAt(key.length-1)))">
          <div class="count">
            {{ isNaN(Number(key.charAt(key.length-1))) ? '':
               isNaN(Number(key.charAt(key.length-2))) ? key.charAt(key.length-1) :
                                                         key.charAt(key.length-2)+key.charAt(key.length-1) }}
          </div>
        </div>
        <div class="name">{{ isNaN(Number(key.charAt(key.length-1))) ? key : 
                             isNaN(Number(key.charAt(key.length-2))) ? key.substr(0,key.length-1) :key.substr(0,key.length-2) }}</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "ResultRoleWeaponList",
  props: {
    roleList: {
      type: Object,
    },
  },
  data(){
    return{
      baseUrl:process.env.VUE_APP_SERVER_PATH
    }
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only --> 
<style scoped lang="less">
// 定义单位数值
@roleUnit: 24px;

//resultRoleBox
.resultRoleBox {
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.roleBox {
  position: relative;
  display: flex;
  flex-direction: column;
  margin: 3px;
  background-color: #fff;

  // 选中效果
  .imgSuccess{
    height: 60px;
    width: 60px;
    position: absolute;
  }

  // 组件角色的图片
  .imgUrl {
    height: 60px;
    width: 60px;
    font-size: 10px;
  }

   // 计数器样式
  .countBox {
    width: 0;
    height: 0;
    border-bottom: 20px solid #087403;
    border-left: 20px solid transparent;
    bottom: 20px;
    position: absolute;
    right: 0;
    bottom: 16px;

    .count {
      width: 16px;
      height: 16px;
      padding: 2px;
      font-size: 10px;
      font-weight: bold;
      color: #ffffff;
      position: absolute;
      right: 0;
      bottom: -20px;
      text-align: right;
      font-family: "Times New Roman", Times, serif;
    }
  }

  // 组件角色的名称
  .name {
    height: 16px;
    line-height: 16px;
    width: 60px;
    font-weight: bold;
    font-size: 0.8rem;
    text-align: center;
    color: #51C0FF;
    background-color: #2E546D;
  }
}
</style>
